package org.scboy.coobi;

import org.scboy.coobi.log.DataAlterLog;
import org.scboy.coobi.log.DataAlterService;
import org.scboy.coobi.runner.StartupRunner;
import org.scboy.coobi.sql.Coobi;
import org.scboy.coobi.sql.factory.EntityFactory;
import org.scboy.dbms.api.IDbManager;
import org.scboy.logger.api.ILoggerManager;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AutoConfigureAfter(value = {org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration.class,Coobi.class,EntityFactory.class})
public class DubboAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(StartupRunner.class)
    @ConditionalOnClass(IDbManager.class)
    @ConditionalOnBean(Coobi.class)
    public StartupRunner initCoobiRunner() {
    	return new StartupRunner();
    }
    
    @Bean
    @ConditionalOnMissingBean(DataAlterService.class)
    @ConditionalOnClass(ILoggerManager.class)
    @ConditionalOnBean(Coobi.class)
    public DataAlterService getDataAlterService() {
		return new DataAlterService();
	}

    @Bean
    @ConditionalOnBean(Coobi.class)
    public DataAlterLog getDataAlterLog() {
		return new DataAlterLog();
	}
}
